import 'package:flutter/material.dart';

/// 一个标题组件
class TagTitle extends StatelessWidget {
  final String title;
  final int maxLine;
  final TextAlign textAlign;
  final TextOverflow overflow;
  final Color? color;
  final double? fontSize;
  final FontWeight fontWeight;
  final EdgeInsets? margin;

  const TagTitle(
    this.title, {
    Key? key,
    this.maxLine = 1,
    this.textAlign = TextAlign.start,
    this.overflow = TextOverflow.ellipsis,
    this.color,
    this.fontSize,
    this.fontWeight = FontWeight.w400,
    this.margin = const EdgeInsets.only(top: 5, bottom: 10),
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final textTheme = Theme.of(context).textTheme.subtitle1;
    return Container(
      margin: margin,
      child: Text(
        title,
        style: TextStyle(
          color: color ?? textTheme?.color,
          fontSize: fontSize ?? textTheme?.fontSize,
          fontWeight: fontWeight,
        ),
        softWrap: true,
        strutStyle: const StrutStyle(height: 1.2),
        textAlign: textAlign,
        maxLines: maxLine,
        overflow: overflow,
      ),
    );
  }
}
